package rad.framework.xml;

import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

public class XmlUtil {
	public static DocumentBuilder newDocumentBuilder() {
		try {
			DocumentBuilderFactory docBuildFactory = DocumentBuilderFactory
					.newInstance();
			return docBuildFactory.newDocumentBuilder();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	public static Document newDocument() {
		return newDocumentBuilder().newDocument();
	}

	public static Document parse(InputStream xml) {
		DocumentBuilder parser = newDocumentBuilder();
		try {
			return parser.parse(xml);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
